/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package Server.domain;

/**
 *
 * @author Ripper
 */
public class MathHelper 
{
    public static double getAngle(Entity from, Entity to)
    {
        return getAngle(from.getX(), from.getY(), to.getX(), to.getY());
    }
    public static double getAngle(Entity ent, double x, double y)
    {
        return getAngle(ent.getX(), ent.getY(), x, y);
    }
    public static double getAngle(double x1, double y1, double x2, double y2)
    {
        double direction = Math.atan2(y1 - y2, x1 - x2);
        direction += Math.PI;
        
        //System.out.println("from ("+x1+","+y1+") to ("+x2+","+y2+") => "+direction);
        
        return direction;
    }
    
    public static double getDistanceBetween(WorldOccupant a, WorldOccupant b)
    {
        return getDistanceBetween(a.getX(), a.getY(), b.getX(), b.getY());
    }
    public static double getDistanceBetween(Entity a, Entity b)
    {
        return getDistanceBetween(a.getX(), a.getY(), b.getX(), b.getY());
    }
    public static double getDistanceBetween(Entity a, WorldOccupant b)
    {
        return getDistanceBetween(a.getX(), a.getY(), b.getX(), b.getY());
    }
    public static double getDistanceBetween(WorldOccupant a, Entity b)
    {
        return getDistanceBetween(a.getX(), a.getY(), b.getX(), b.getY());
    }
    public static double getDistanceBetween(WorldOccupant a, double newX, double newY)
    {
        return getDistanceBetween(a.getX(), a.getY(), newX, newY);
    }
    public static double getDistanceBetween(double x1, double y1, double x2, double y2)
    {
        return Math.sqrt(Math.pow(x1 - x2,2) + Math.pow(y1 - y2,2));
    }
}
